Skip to content

Player Counter: Add Arma 3 and Arma Reforger support and improve Source query#115

Closed
szpolny wants to merge 3 commits intopelican-dev:mainfrom
szpolny:player-counter/arma
Closed

Player Counter: Add Arma 3 and Arma Reforger support and improve Source query#115
szpolny wants to merge 3 commits intopelican-dev:mainfrom
szpolny:player-counter/arma

Conversation

@szpolny
Copy link
Contributor

@szpolny szpolny commented Feb 27, 2026

This pull request introduces support for Arma 3 and Arma Reforger server types to the Player Counter plugin, along with improvements for more robust server information querying and error handling.

New server type support

  • Added Arma3QueryTypeSchema and ArmaReforgerQueryTypeSchema classes to support querying Arma 3 and Arma Reforger servers. [1] [2]
  • Registered the new schemas in the PlayerCounterPluginProvider so they are available for use. [1] [2]

Plugin metadata

  • Updated the plugin version in plugin.json to 1.1.0 to reflect the new features.

Summary by CodeRabbit

  • New Features

    • Added support for querying Arma 3 servers
    • Added support for querying Arma Reforger servers
  • Bug Fixes

    • Improved null safety and error handling in server query operations
  • Chores

    • Plugin metadata updated to version 1.1.0

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

Warning

Rate limit exceeded

@szpolny has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 43 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 43f16be and b0cfcb3.

📒 Files selected for processing (4)
  • player-counter/src/Extensions/Query/Schemas/CitizenFXQueryTypeSchema.php
  • player-counter/src/Extensions/Query/Schemas/GoldSourceQueryTypeSchema.php
  • player-counter/src/Extensions/Query/Schemas/MinecraftJavaQueryTypeSchema.php
  • player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php
📝 Walkthrough

Walkthrough

This PR adds Arma 3 and Arma Reforger query type schemas, hardens the base SourceQueryTypeSchema with null-safe defaults and an early exit, updates plugin version to 1.1.0, and registers the new schemas in the plugin provider.

Changes

Cohort / File(s) Summary
Version Update
player-counter/plugin.json
Bumped plugin version from 1.0.0 to 1.1.0.
New Query Type Schemas
player-counter/src/Extensions/Query/Schemas/Arma3QueryTypeSchema.php, player-counter/src/Extensions/Query/Schemas/ArmaReforgerQueryTypeSchema.php
Added two classes extending SourceQueryTypeSchema, each implementing getId(): string and getName(): string for arma3 and arma-reforger.
Base Schema Hardening
player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php
Added early return when GetInfo() is falsy, null-safe defaults/casts for hostname, map, player counts, and player fields; ensures players mapping uses safe defaults.
Service Registration
player-counter/src/Providers/PlayerCounterPluginProvider.php
Imported and registered Arma3QueryTypeSchema and ArmaReforgerQueryTypeSchema in the plugin provider registration flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐇 I hopped through code to add a tune,

Two Arma types beneath the moon,
Nulls caught softly, defaults set right,
Version bumped and services bright,
Paws on keys, I celebrate tonight!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main changes: adding Arma 3 and Arma Reforger support and improving Source query functionality, which aligns with all the modifications present in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php`:
- Around line 41-51: Modify SourceQueryTypeSchema so its 'players' field uses
null as a sentinel when the query does not support a player list: call
$query->GetPlayers() and if it returns false/unsupported return null for
'players' instead of an empty array; update the array_map only when $players is
an array. This aligns SourceQueryTypeSchema with MinecraftBedrockQueryTypeSchema
and lets PlayerCounterController::players() (the is_null($data['players'])
check) behave as intended.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 47f93e0 and d749ee4.

📒 Files selected for processing (5)
  • player-counter/plugin.json
  • player-counter/src/Extensions/Query/Schemas/Arma3QueryTypeSchema.php
  • player-counter/src/Extensions/Query/Schemas/ArmaReforgerQueryTypeSchema.php
  • player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php
  • player-counter/src/Providers/PlayerCounterPluginProvider.php
📜 Review details
🧰 Additional context used
🧬 Code graph analysis (4)
player-counter/src/Extensions/Query/Schemas/ArmaReforgerQueryTypeSchema.php (2)
player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php (1)
  • SourceQueryTypeSchema (9-61)
player-counter/src/Extensions/Query/Schemas/Arma3QueryTypeSchema.php (2)
  • getId (7-10)
  • getName (12-15)
player-counter/src/Providers/PlayerCounterPluginProvider.php (3)
player-counter/src/Extensions/Query/Schemas/Arma3QueryTypeSchema.php (1)
  • Arma3QueryTypeSchema (5-16)
player-counter/src/Extensions/Query/Schemas/ArmaReforgerQueryTypeSchema.php (1)
  • ArmaReforgerQueryTypeSchema (5-16)
player-counter/src/Extensions/Query/QueryTypeService.php (1)
  • register (15-22)
player-counter/src/Extensions/Query/Schemas/Arma3QueryTypeSchema.php (2)
player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php (1)
  • SourceQueryTypeSchema (9-61)
player-counter/src/Extensions/Query/Schemas/ArmaReforgerQueryTypeSchema.php (2)
  • getId (7-10)
  • getName (12-15)
player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php (1)
player-counter/src/Http/Controllers/Api/Client/Servers/PlayerCounterController.php (2)
  • players (37-49)
  • query (23-28)
🪛 GitHub Check: PHPStan (8.2)
player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php

[failure] 37-37:
Strict comparison using === between array and false will always evaluate to false.

🪛 GitHub Check: PHPStan (8.3)
player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php

[failure] 37-37:
Strict comparison using === between array and false will always evaluate to false.

🪛 GitHub Check: PHPStan (8.4)
player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php

[failure] 37-37:
Strict comparison using === between array and false will always evaluate to false.

🪛 GitHub Check: PHPStan (8.5)
player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php

[failure] 37-37:
Strict comparison using === between array and false will always evaluate to false.

🔇 Additional comments (6)
player-counter/plugin.json (1)

5-5: LGTM!

Version bump to 1.1.0 appropriately reflects the addition of new features (Arma 3 and Arma Reforger support) following semantic versioning.

player-counter/src/Extensions/Query/Schemas/Arma3QueryTypeSchema.php (1)

5-16: LGTM!

Clean and minimal implementation. Arma 3 uses the Steam/Source query protocol, so extending SourceQueryTypeSchema is appropriate.

player-counter/src/Providers/PlayerCounterPluginProvider.php (2)

10-11: LGTM!

Imports are correctly added following the existing alphabetical ordering pattern.


40-41: LGTM!

New query type schemas are properly registered following the established pattern.

player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php (1)

37-39: The check is correct and necessary.

The xPaw/PHP-Source-Query GetInfo() method returns bool|array — array on success, false on failure. The comparison if ($info === false) is valid defensive code and should be retained.

Likely an incorrect or invalid review comment.

player-counter/src/Extensions/Query/Schemas/ArmaReforgerQueryTypeSchema.php (1)

5-16: No changes required. Arma Reforger supports the standard Valve Source/Steam server query protocol (A2S), which is what SourceQuery::SOURCE implements. The implementation correctly inherits from SourceQueryTypeSchema without custom engine handling, consistent with how Arma 3 is configured.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php (1)

41-51: ⚠️ Potential issue | 🟠 Major

Preserve null for unsupported player lists (not []).

Line 41 currently coerces GetPlayers() failures/unsupported states into an empty array, which bypasses PlayerCounterController::players() null check and changes API semantics (unsupported vs empty). This should stay distinguishable.

Proposed fix
-            $players = $query->GetPlayers() ?: [];
+            $players = $query->GetPlayers();
@@
-                'players' => array_map(fn ($player) => [
-                    'id' => (string) ($player['Id'] ?? ''),
-                    'name' => (string) ($player['Name'] ?? 'Unknown'),
-                ], $players),
+                'players' => is_array($players)
+                    ? array_map(fn ($player) => [
+                        'id' => (string) ($player['Id'] ?? ''),
+                        'name' => (string) ($player['Name'] ?? 'Unknown'),
+                    ], $players)
+                    : null,

Also update the return phpdoc on Line 21 and Line 27 to allow players: null|array<array{id: string, name: string}>.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php` around
lines 41 - 51, The code currently forces $query->GetPlayers() into an empty
array which hides "unsupported" results and breaks
PlayerCounterController::players() null checks; change the handling in
SourceQueryTypeSchema (where $players is assigned from $query->GetPlayers()) to
keep null when GetPlayers() indicates unsupported (do not coerce to []), and
update the method/class return phpdoc (the docblocks referenced around Line 21
and Line 27) to reflect 'players: null|array<array{id: string, name: string}>'
so consumers know players may be null.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php`:
- Around line 41-51: The code currently forces $query->GetPlayers() into an
empty array which hides "unsupported" results and breaks
PlayerCounterController::players() null checks; change the handling in
SourceQueryTypeSchema (where $players is assigned from $query->GetPlayers()) to
keep null when GetPlayers() indicates unsupported (do not coerce to []), and
update the method/class return phpdoc (the docblocks referenced around Line 21
and Line 27) to reflect 'players: null|array<array{id: string, name: string}>'
so consumers know players may be null.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d749ee4 and 43f16be.

📒 Files selected for processing (1)
  • player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php
📜 Review details
🧰 Additional context used
🧬 Code graph analysis (1)
player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php (1)
player-counter/src/Http/Controllers/Api/Client/Servers/PlayerCounterController.php (2)
  • players (37-49)
  • query (23-28)
🔇 Additional comments (2)
player-counter/src/Extensions/Query/Schemas/SourceQueryTypeSchema.php (2)

37-39: Good defensive early-return on missing query info.

The guard on Line 37-39 prevents invalid data propagation and keeps failure handling explicit.


44-47: Null-safe typed defaults look solid.

The fallback casts on Line 44-47 make the response shape stable under partial Source responses.

@szpolny szpolny force-pushed the player-counter/arma branch from b0cfcb3 to 43f16be Compare February 27, 2026 23:49
@Boy132
Copy link
Member

Boy132 commented Feb 28, 2026

Thanks but this isn't needed. You can simply use the Source query.

@Boy132 Boy132 closed this Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants